﻿using System;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using OpenQA.Selenium;

namespace FromScratch.Tests
{
    public static class WebDriverExtensionMethods
    {
        public static bool IsElementPresentAndVisible(this IWebDriver driver, By by)
        {
            var elements = driver.FindElements(by);
            if (elements.Count == 0)
                return false;

            return elements.Any(element => element.Displayed);
        }
    }
}
